(function(vc){
    vc.extends({
        propTypes: {
           emitChooseAffiliateUser:vc.propTypes.string,
           emitLoadData:vc.propTypes.string
        },
        data:{
            chooseAffiliateUserInfo:{
                affiliateUsers:[],
                _currentAffiliateUserName:'',
            }
        },
        _initMethod:function(){
        },
        _initEvent:function(){
            vc.on('chooseAffiliateUser','openChooseAffiliateUserModel',function(_param){
                $('#chooseAffiliateUserModel').modal('show');
                vc.component._refreshChooseAffiliateUserInfo();
                vc.component._loadAllAffiliateUserInfo(1,10,'');
            });
        },
        methods:{
            _loadAllAffiliateUserInfo:function(_page,_row,_name){
                var param = {
                    params:{
                        page:_page,
                        row:_row,
                        communityId:vc.getCurrentCommunity().communityId,
                        name:_name
                    }
                };

                //发送get请求
               vc.http.apiGet('affiliateUser.listAffiliateUser',
                             param,
                             function(json){
                                var _affiliateUserInfo = JSON.parse(json);
                                vc.component.chooseAffiliateUserInfo.affiliateUsers = _affiliateUserInfo.affiliateUsers;
                             },function(){
                                console.log('请求失败处理');
                             }
                           );
            },
            chooseAffiliateUser:function(_affiliateUser){
                if(_affiliateUser.hasOwnProperty('name')){
                     _affiliateUser.affiliateUserName = _affiliateUser.name;
                }
                vc.emit($props.emitChooseAffiliateUser,'chooseAffiliateUser',_affiliateUser);
                vc.emit($props.emitLoadData,'listAffiliateUserData',{
                    affiliateUserId:_affiliateUser.affiliateUserId
                });
                $('#chooseAffiliateUserModel').modal('hide');
            },
            queryAffiliateUsers:function(){
                vc.component._loadAllAffiliateUserInfo(1,10,vc.component.chooseAffiliateUserInfo._currentAffiliateUserName);
            },
            _refreshChooseAffiliateUserInfo:function(){
                vc.component.chooseAffiliateUserInfo._currentAffiliateUserName = "";
            }
        }

    });
})(window.vc);
